//
//  Net.m
//  Computer
//
//  Created by qianfeng on 15/10/21.
//  Copyright © 2015年 qianfeng. All rights reserved.
//

#import "Net.h"

#import "AFHTTPRequestOperationManager.h"

@implementation Net

+(void)getHttpURL:(NSString *)url completation:(SuccessBlock)success failure:(FailureBlock)failure{
    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
    [manager.responseSerializer setAcceptableContentTypes:[NSSet setWithObject:@"text/html"]];
    [manager GET:url parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
        //回调block，同时传值
        success(responseObject);
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        failure(error);
    }];
}
+(void)postHttpURL:(NSString *)url parameter:(NSDictionary *)parameter completation:(SuccessBlock)success failure:(FailureBlock)failure{
    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
    [manager POST:url parameters:parameter success:^(AFHTTPRequestOperation *operation, id responseObject) {
        success(responseObject);
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        failure(error);
    }];
    
}
+(void)setNetworkActivityIndicator:(BOOL)bo{
    UIApplication *app = [UIApplication sharedApplication];
    [app setNetworkActivityIndicatorVisible:YES];
}
@end
